<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<html:html>
<head>
<script type="text/javascript">
function validate(form) {
	if(form.state == null)
		return true;
	var x = form.state.value;
	if (x == null || x == "") {
		alert("State is required.");
   		return false;
    }
	return true;
}
</script>
<title>Address</title>
</head>
<body>
	<bean:write name="nameForm" property="firstName" scope="session" />
	<bean:write name="nameForm" property="middleInit" scope="session" />
	<bean:write name="nameForm" property="lastName" scope="session" />
	<bean:write name="nameForm" property="citizenship" scope="session" />
	<br>
	<bean:write name="citizenshipForm" property="citizenship"
		scope="session" />
	<br>
	<bean:write name="residenceForm" property="residence" scope="session" />
	<br>
	<html:form action="/address" method="POST"
		onsubmit="return validateAddressForm(this) && validate(this);">
		<table border=0>
			<tr>
				<td>Street Address</td>
				<td><html:text property="street" size="30" />
				</td>
			</tr>
			<tr>
				<td>City</td>
				<td><html:text property="city" size="20" />
				</td>
			</tr>
			<logic:equal name="residenceForm" property="residence"
				value="United States">
				<tr>
					<td>State</td>
					<td><html:text property="state" size="2" />
					</td>
				</tr>
			</logic:equal>
			<tr>
				<td>Zip Code</td>
				<td><html:text property="zipCode" size="6" />
				</td>
			</tr>

			<tr>
				<td>Telephone</td>
				<td><logic:notEqual name="residenceForm" property="residence"
						value="United States">
						<html:text property="countryCode" size="4" />
					</logic:notEqual> <html:text property="areaCode" size="3" /> <html:text
						property="telephone" size="8" />
				</td>
			</tr>

			<tr>
				<td><html:submit>Submit</html:submit>
				</td>
				<td><html:reset>Reset</html:reset>
				</td>
			</tr>
			<html:javascript formName="addressForm" />
		</table>
	</html:form>
</body>
</html:html>